<template>
	<!--POP画册/POP下单/道具下单 图片列表-->
	<view class="com-box" @click.stop="toDet(obj.id,obj.title)">
		<image class="com-box-img" :src="obj.img" mode="aspectFill"></image>
		<image class="sel-img" :src="$mAssetsPath.icon_replace" v-if="objstatu.replace_statu" @click.stop="replace_img(obj)"></image>
		<view class="com-box-r">
			<view class="com-box-r-name">{{obj.name || obj.title}}</view>
			<view class="com-box-icons" v-if="objstatu.stick_del_statu">
				<view class="com-box-icon">
					<view class="com-box-i" @click.stop="checked(obj.id,obj.top)"><image class="icon-tb" :src="obj.top===1?$mAssetsPath.icon_qx:$mAssetsPath.icon_zd"></image>{{obj.top===1?'取消':'置顶'}}</view>
					<view class="com-box-i" @click.stop="deleted(obj.id)"><image class="icon-tb" :src="$mAssetsPath.icon_sc"></image>删除</view>
				</view>
			</view>
		</view>
		<!--编辑框-->
		<w-popup :show="showtip" :type="type1" @change="change1">
			<view class="w-tip">
				<view class="w-tit">提示</view>
				<view class="w-con">
					<view class="txt-row">是否确认删除？</view>
				</view>
				<view class="w-but">
					<view class="w-but-txt" @click="cancel('tip')">取消</view>
					<view class="w-but-txt" @click="confirm">确认</view>
				</view>
			</view>
		</w-popup>
	</view>
</template>

<script>
	export default {
		name: "com-top",
		components: {},
		props: {
			obj: {
				type: Object,
				default () {
					return {
						id:1,
						head_img: '/static/data-img/img.jpg',
						title: '张三',
						statu:1,
						stick_statu:1 //1-置顶
					}
				}
			},
			objstatu: {
				type: Object,
				default () {
					return {
						replace_statu:1,
						stick_del_statu:1 //1-置顶
					}
				}
			}
		},
		data() {
			return {
				showtip: false, //是否显示弹窗1
				content1: '顶部弹 popup',
				type1: '', //弹窗显示方式
				selIndex:''
			}
		},
		methods:{
			replace_img(item){
				this.$emit('replace_img',item)
			},
			checked(id,top){
				this.$emit('checked',id,top)
			},
			deleted(id){
				this.$emit('deleted',id)
				/* this.content1 = 'center'
				this.type1 = 'center';
				this.showtip = true;
				this.selIndex = id */
			},
			toDet(id,title){
				this.$emit('toDet',id,title)
			},
			confirm(){
				this.$emit('deleted',this.selIndex)
				this.showtip = false;
			},
			change1(e) {
				if (!e.show) {
					this.showtip = false;
				}
			},
			//取消
			cancel(type) {
				this['show' + type] = false
			},
		}
	}
</script>

<style lang="scss" scoped>
	/* 提示窗口 */
	.w-tip {
		/* #ifndef APP-NVUE */
		display: flex;
		flex-direction: column;
		/* #endif */
		width: 70vw;
		border-radius: 10rpx;
		background-color: #fff;
		box-shadow: 0rpx 7rpx 7rpx 0rpx rgba(0, 0, 0, 0.1);
		margin: 30rpx auto 0;
	
		.w-tit {
			font-size: 36rpx;
			font-weight: bold;
			color: $font-color-3;
			line-height: 60rpx;
			height: 60rpx;
			margin-top: 20rpx;
			text-align: center;
		}
	
		.w-but {
			display: flex;
			font-size: 32rpx;
			font-weight: 400;
			color: $font-color-b3;
			height: 84rpx;
			line-height: 84rpx;
	
			.w-but-txt {
				flex: 1;
				text-align: center;
				border-right: 1rpx solid #f5f5f5;
			}
	
			.w-but-txt:last-of-type {
				border-right: none;
			}
		}
	
		.w-con {
			display: flex;
			text-align: center;
			font-weight: 400;
			padding: 30rpx 30rpx;
			border-bottom: 1rpx solid #f5f5f5;
	
			.txt-row {
				width: 100%;
				text-align: center;
				font-size: 28rpx;
				color: $font-color-9;
			}
		}
	}
	.com-box {
		display: flex;
		flex-direction: column;
		position: relative;
		
		.sel-img{
			position: absolute;
			right: 30rpx;
			top: 30rpx;
			width: 60rpx;
			height: 60rpx;
		}
		.com-box-img{
			width: 100%;
			height: 388rpx;
			border-radius: 10rpx;
			margin-bottom: 20rpx;
			
		}
		.com-box-r{
			display: flex;
			justify-content: space-between;
			.com-box-r-name{
				width: calc(100% - 300rpx);
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				font-size: 32rpx;
				font-weight: 400;
				color: $font-color-3;
				height: 72rpx;
				line-height: 72rpx;
				margin-bottom: 20rpx;
			}
			.com-box-icons{
				display: flex;
				width: 280rpx;
				flex-direction: row-reverse;
				
				.com-box-icon{
					display: flex;
					height: 72rpx;
					background: #F5F5F5;
					border-radius: 6rpx;
					padding: 20rpx 0;
					.com-box-i{
						flex: 1;
						display: flex;
						align-items: center;
						padding:0rpx 20rpx;
						font-size: 28rpx;
						line-height: 40rpx;
						color:$font-color-9;
						border-right: 1rpx solid $font-color-9;
						.icon-tb{
							width: 32rpx;
							height:32rpx;
							margin-right: 10rpx;
						}
					}
					.com-box-i:last-of-type{
						border-right: none;
						margin-right:0;
					}
				}
			}
		}
		
 	}
</style>
